package org.ecpkn.PAGridSim.core.offlineOptimization.workloadBalance;

import java.util.Comparator;

import org.ecpkn.PAGridSim.core.gridsimEntity.paMachine.PAMachine;
import org.ecpkn.PAGridSim.core.tasksCreation.Task;

public class ComparatorTaskUtilization implements Comparator<Task> {
	public int compare(Task t0, Task t1) {
		// Avoid 0.** becoming 0 when cast double to in
		int factor = 10000;
		// Largest Utilization first
		int flagUtilization = 0;
		double u0 = t0.getUtilization(PAMachine.MAXRATING);
		double u1 = t1.getUtilization(PAMachine.MAXRATING);
		flagUtilization = (int) (u1 * factor - u0 * factor);
		return flagUtilization;

	}
}
